/*
 * Param.h
 *
 *  Created on: Dec 17, 2014
 *      Author: Phong
 */

#ifndef PARAM_H_
#define PARAM_H_

#include "Dictionary.h"
#include "Matrix.h"
#include "SafeShare.h"
#include <vector>
#include <fstream>
#include <random>
using namespace std;

class Param : public SafeShare {
public:
    Param() : SafeShare() {}

	vector<Matrix*> weights;
	int nMatricesWoWE;
    int refCount;

	Matrix *Ww, *bw;

	Matrix *anonRep[2];

	// for computing composition rept.
	Matrix *Wch, *bc;
	vector<Matrix*> Wc[2];

	// for computing generation rept.
	Matrix *Wgh[2], *Wgp[2], *bg[2];
	vector<Matrix*> Wg[2];

	// for computing partial gen. rept
	Matrix *Wgh_p[2], *Wgp_p[2], *Wgs_p[2], *bg_p[2];
	Matrix *Wtr[2], *btr[2];
	vector<Matrix*> Wg_p[2];

	// for generating pos/deprel/word/cap
	Matrix *Wdr, *bdr;
	Matrix *Wpos, *Wdrpos, *bpos;

	vector<Matrix*> Wword;
	Matrix *Wdrword, *Wposword, *bword;

	// pos/cap/word embeddings
	vector<Matrix*> Lpos, Lcap, L;

	Param (int dim, int wdim, int nwords, int npos, int ndeprel, real r1, real r2);
    
	void fill(real value);
    
    void save(ofstream& f);
    static Param* load(ifstream &f);
    
protected:
    virtual ~Param();
};

#endif /* PARAM_H_ */
